using System;
using System.Collections.Generic;
using Com.Binaria.Core.Dto;

namespace Com.Binaria.SISCOB.Funcional.DTO 
{

    [Serializable]
    public class CartolaFuncionalDTO : PaginadoDTO
    {

        public System.Int32? Id
        {
            get;
            set;
        }

        public System.Int32 CuentaCorriente
        {
            get;
            set;
        }

        public System.Int32 Folio
        {
            get;
            set;
        }

        public System.DateTime? FchEmision
        {
            get;
            set;
        }

        public string FchEmisionText
        {
            get
            {
                if (FchEmision.HasValue && FchEmision.Value.Year > 1000)
                    return string.Format("{0}/{1}/{2}", FchEmision.Value.Day.ToString("00"), FchEmision.Value.Month.ToString("00"), FchEmision.Value.Year.ToString("0000"));
                return string.Empty;
            }
            set
            {
                FchEmision = null;
                if (!string.IsNullOrEmpty(value))
                {
                    string[] sVal = value.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries);
                    if (sVal.Length == 3)
                        FchEmision = new DateTime(Convert.ToInt32(sVal[2]), Convert.ToInt32(sVal[1]), Convert.ToInt32(sVal[0]));
                }
            }
        }

        public System.DateTime? FchDesde
        {
            get;
            set;
        }

        public string FchDesdeText
        {
            get
            {
                if (FchDesde.HasValue && FchDesde.Value.Year > 1000)
                    return string.Format("{0}/{1}/{2}", FchDesde.Value.Day.ToString("00"), FchDesde.Value.Month.ToString("00"), FchDesde.Value.Year.ToString("0000"));
                return string.Empty;
            }
            set
            {
                FchDesde = null;
                if (!string.IsNullOrEmpty(value))
                {
                    string[] sVal = value.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries);
                    if (sVal.Length == 3)
                        FchDesde = new DateTime(Convert.ToInt32(sVal[2]), Convert.ToInt32(sVal[1]), Convert.ToInt32(sVal[0]));
                }
            }
        }

        public System.DateTime? FchHasta
        {
            get;
            set;
        }

        public string FchHastaText
        {
            get
            {
                if (FchHasta.HasValue && FchHasta.Value.Year > 1000)
                    return string.Format("{0}/{1}/{2}", FchHasta.Value.Day.ToString("00"), FchHasta.Value.Month.ToString("00"), FchHasta.Value.Year.ToString("0000"));
                return string.Empty;
            }
            set
            {
                FchHasta = null;
                if (!string.IsNullOrEmpty(value))
                {
                    string[] sVal = value.Split(new char[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries);
                    if (sVal.Length == 3)
                        FchHasta = new DateTime(Convert.ToInt32(sVal[2]), Convert.ToInt32(sVal[1]), Convert.ToInt32(sVal[0]));
                }
            }
        }

        public System.String Usuario
        {
            get;
            set;
        }

        string _Text = string.Empty;
        public string Text
        {
            get { return string.IsNullOrEmpty(_Text) ? Id.ToString() : _Text; }
        }

        public IList<ItemCartolaFuncionalDTO> ItemCartola
        {
            get;
            set;
        }
    }
}
